package com.restaurantonlineorder.oauth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.restaurantonlineorder.oauth.domain.User;
import com.restaurantonlineorder.oauth.mapper.UserMapper;
import com.restaurantonlineorder.oauth.service.IUserService;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * @author 熊宇
 * @date 2022/7/20 21:46
 * @description 买家信息相关 实现类
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserDetailsService, IUserService {


    @Override
    public UserDetails loadUserByUsername(String phone) throws UsernameNotFoundException {
        LambdaQueryWrapper<User> queryWrapper = Wrappers.lambdaQuery(User.class);
        queryWrapper.eq(User::getPhone, phone);
        User user = this.baseMapper.selectOne(queryWrapper);
        return user;
    }
}
